-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement :read typed command #3966
Conversation
Thanks for working on this! Would it be possible to integrate this with the file picker? Might be a separate PR though |
55a4b8e
to
109fd55
Compare
@kirawi I have copied and used a trimmed down version of I appreciate it if you can have a look and let me know if you suggest any changes. |
504b26f
to
43c1951
Compare
} | ||
|
||
/// Stripped down version of [`helix_view::document::from_reader`] which is adapted to use encoding_rs::Decoder::read_to_string | ||
fn from_reader<R: std::io::Read + ?Sized>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicates a lot of code between this function and document::from_reader
. Can you factor out the shared parts and share the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I was following @kirawi's advice on this: #3966 (comment)
I can try working something out at the expense of dragging this PR further, or that work can be the subject of another PR. I am easy either way. It's all up to the maintainers at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can use read_to_string
from document now:
helix/helix-view/src/document.rs
Lines 474 to 477 in 636c91c
pub fn read_to_string<R: std::io::Read + ?Sized>( | |
reader: &mut R, | |
encoding: Option<&'static Encoding>, | |
) -> Result<(String, &'static Encoding, bool), Error> { |
How about |
@sudormrfbin I have named it |
Vi We already have |
`read_file` method is a stripped down version of `helix_view::document::from_reader`
Resurrects helix-editor#3966. This is 100% @idursun's work. Using read_to_string from helix-editor#7431. Co-authored-by: [email protected]
Resurrects helix-editor#3966. This is 100% @idursun's work. Using read_to_string from helix-editor#7431. Co-authored-by: [email protected]
closing in favor of #10447 |
This is a naive attempt at partially implementing #3796
Adds a typed command
:read
with alias:r
(following vim) that reads the contents of a file into the current buffer.At this stage, I just would like to validate my approach and obviously would love to finish it off after implementing some integration tests.
I also appreciate any pointers and guidance around reading the file contents into the buffer more efficiently. I am loading the file into a String for now.